package com.flca.frw.util
{
	public class Hash 
	{
		public static function calcInt(aValue:int):int
		{
			return aValue;
		}
		
		public static function calcNumber(aValue:Number):int
		{
			return calcString(String(aValue));
		}
		
		public static function calcStringArray(aValues:Array):int
		{
			var result:int;
			
			result = 0;
			if (aValues != null)
			{
	            for (var i:int = 0; i < aValues.length; i++) 
	            {
	                result += calcString(aValues[i] as String);
	            }
	  		}
            
	        return result;
		}
		
		public static function calcString(aValue:String):int
		{
			var result:int;
			
			result = 0;
			if (aValue != null)
			{
	            for (var i:int = 0; i < aValue.length; i++) 
	            {
	                result = 31 * result + aValue.charCodeAt(i);
	            }
	  		}
            
	        return result;
		}
		
		public static function calcBoolean(aValue:Boolean):int
		{
			return aValue ? 1231 : 1237;
		}
		
		public static function calcDate(aValue:Date):int
		{
			return aValue != null ? calcNumber(aValue.time) : 0;
		}
	}
}